home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-9.10-netbook-remix-PL.iso / casper / filesystem.squashfs / usr / lib / python2.6 / lib-tk / tkMessageBox.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2009-11-11  |  4KB  |  105 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. from tkCommonDialog import Dialog
  5. ERROR = 'error'
  6. INFO = 'info'
  7. QUESTION = 'question'
  8. WARNING = 'warning'
  9. ABORTRETRYIGNORE = 'abortretryignore'
  10. OK = 'ok'
  11. OKCANCEL = 'okcancel'
  12. RETRYCANCEL = 'retrycancel'
  13. YESNO = 'yesno'
  14. YESNOCANCEL = 'yesnocancel'
  15. ABORT = 'abort'
  16. RETRY = 'retry'
  17. IGNORE = 'ignore'
  18. OK = 'ok'
  19. CANCEL = 'cancel'
  20. YES = 'yes'
  21. NO = 'no'
  22.  
  23. class Message(Dialog):
  24.     '''A message box'''
  25.     command = 'tk_messageBox'
  26.  
  27.  
  28. def _show(title = None, message = None, _icon = None, _type = None, **options):
  29.     if _icon and 'icon' not in options:
  30.         options['icon'] = _icon
  31.     
  32.     if _type and 'type' not in options:
  33.         options['type'] = _type
  34.     
  35.     if title:
  36.         options['title'] = title
  37.     
  38.     if message:
  39.         options['message'] = message
  40.     
  41.     res = Message(**options).show()
  42.     if isinstance(res, bool):
  43.         if res:
  44.             return YES
  45.         return NO
  46.     return res
  47.  
  48.  
  49. def showinfo(title = None, message = None, **options):
  50.     '''Show an info message'''
  51.     return _show(title, message, INFO, OK, **options)
  52.  
  53.  
  54. def showwarning(title = None, message = None, **options):
  55.     '''Show a warning message'''
  56.     return _show(title, message, WARNING, OK, **options)
  57.  
  58.  
  59. def showerror(title = None, message = None, **options):
  60.     '''Show an error message'''
  61.     return _show(title, message, ERROR, OK, **options)
  62.  
  63.  
  64. def askquestion(title = None, message = None, **options):
  65.     '''Ask a question'''
  66.     return _show(title, message, QUESTION, YESNO, **options)
  67.  
  68.  
  69. def askokcancel(title = None, message = None, **options):
  70.     '''Ask if operation should proceed; return true if the answer is ok'''
  71.     s = _show(title, message, QUESTION, OKCANCEL, **options)
  72.     return s == OK
  73.  
  74.  
  75. def askyesno(title = None, message = None, **options):
  76.     '''Ask a question; return true if the answer is yes'''
  77.     s = _show(title, message, QUESTION, YESNO, **options)
  78.     return s == YES
  79.  
  80.  
  81. def askyesnocancel(title = None, message = None, **options):
  82.     '''Ask a question; return true if the answer is yes, None if cancelled.'''
  83.     s = _show(title, message, QUESTION, YESNOCANCEL, **options)
  84.     s = str(s)
  85.     if s == CANCEL:
  86.         return None
  87.     return s == YES
  88.  
  89.  
  90. def askretrycancel(title = None, message = None, **options):
  91.     '''Ask if operation should be retried; return true if the answer is yes'''
  92.     s = _show(title, message, WARNING, RETRYCANCEL, **options)
  93.     return s == RETRY
  94.  
  95. if __name__ == '__main__':
  96.     print 'info', showinfo('Spam', 'Egg Information')
  97.     print 'warning', showwarning('Spam', 'Egg Warning')
  98.     print 'error', showerror('Spam', 'Egg Alert')
  99.     print 'question', askquestion('Spam', 'Question?')
  100.     print 'proceed', askokcancel('Spam', 'Proceed?')
  101.     print 'yes/no', askyesno('Spam', 'Got it?')
  102.     print 'yes/no/cancel', askyesnocancel('Spam', 'Want it?')
  103.     print 'try again', askretrycancel('Spam', 'Try again?')
  104.  
  105.